package com.example.mylibrarybase.yumengmeng04.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.mylibrarybase.R;
import com.example.mylibrarybase.bar.initAction_Bar;
import com.example.mylibrarybase.base.baseui.BaseActivity;
import com.example.mylibrarybase.base.texstListViewAdapter;
import com.example.mylibrarybase.bean.Item_base;
import com.example.mylibrarybase.utils.Utils;
import com.example.mylibrarybase.view.MyListView;

import java.util.ArrayList;

public class MainActivity_04 extends BaseActivity {

    private MyListView mBase_activity_listview_04;
    private initAction_Bar mBase_action_bar;
    private ArrayList<Item_base> mMItem_bases;
    private texstListViewAdapter mMyListViewAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    @Override
    public int getlayouXML() {
        return R.layout.activity_main_04;
    }

    @Override
    public void initView() {
        mBase_action_bar = (initAction_Bar) findViewById(R.id.base_action_bar);
        mBase_action_bar.setCallBack(new initAction_Bar.Action_bar_call_back() {
            @Override
            public void getAction_barView_backbutton(TextView textView) {

            }

            @Override
            public void getAction_barView_backbutton_icon(ImageView imageView) {

            }

            @Override
            public void getAction_barView_title(TextView textView) {
                textView.setText("listView详细");
            }

            @Override
            public void getAction_barView_right_icon(ImageView imageView) {

            }
        });
        mBase_activity_listview_04 = (MyListView) findViewById(R.id.base_activity_listview_04);


        initData();
    }

    @Override
    public void initData() {
        mMItem_bases = new ArrayList<>();
        mMItem_bases.add(new Item_base("1单条目listView"));
        mMItem_bases.add(new Item_base("2多条目listView"));
        mMItem_bases.add(new Item_base("3选取图片在列表上显示"));

        mMyListViewAdapter = new texstListViewAdapter(this, mMItem_bases);
        mBase_activity_listview_04.setAdapter(mMyListViewAdapter);
        initLishner();
    }

    private void initLishner() {

        mBase_activity_listview_04.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                switch (i){
                    case 0:
                        Utils.start_Activity(MainActivity_04.this, MainActivity_04_listsingle.class);
                    break;
                    case 1:
                        Utils.start_Activity(MainActivity_04.this, MainActivity.class);
                    break;
                    case 2:
                        Utils.start_Activity(MainActivity_04.this, MainActivity_04_listsingle.class);
                    break;
                }
            }
        });
    }
}
